// XException.cpp: implementation of the CXException class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "XLibDemo.h"
#include "XException.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CXException::CXException(CString errMsg, DWORD errCode)
{
	m_errMsg = errMsg;
	m_errCode = errCode;
}

CString CXException::GetErrMsg()
{
	return m_errMsg;
}

DWORD CXException::GetErrCode()
{
	return m_errCode;
}

CString CXException::GetErrMsgByCode()
{
	TCHAR *buff = NULL;
	::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
			FORMAT_MESSAGE_FROM_SYSTEM,
			NULL,
			m_errCode,
			0,
			(LPTSTR)&buff,
			0,
			NULL);
	CString msg(buff);
	LocalFree(buff);
	return msg;
}

CXException::~CXException()
{

}
